import { v4 } from 'uuid'

import { DataMap } from '@grapecity/wijmo.grid';
import { format, DateTime, isFunction } from '@grapecity/wijmo';

export const catalogue = [
    {
        key: 'A',
        label: 'A-数据绑定',
        children: [
            { key: 'A01', label: '基础知识' },
            { key: 'A02', label: '无限滚动' },
            { key: 'A03', label: '可编辑网格' },
        ],
    },
    {
        key: 'B',
        label: 'B-列',
        children: [
            { key: 'B01', label: '列宽' },
            {
                key: 'B02',
                label: '数据映射',
                children: [
                    { key: 'B0201', label: '简单映射' },
                    { key: 'B0202', label: '动态映射' },
                    { key: 'B0203', label: 'DataMap编辑器' },
                ]
            },
            { key: 'B03', label: '列选择器' },
            { key: 'B04', label: '排序方式' },
            { key: 'B05', label: '列选择' },
            { key: 'B06', label: '冻结' },
            { key: 'B07', label: '固定列' },
            { key: 'B08', label: '列组' },
        ],
    },
    {
        key: 'C',
        label: 'C-行',
        children: [
            { key: 'C01', label: '添加删除' },
            { key: 'C02', label: '单元格填充' },
            { key: 'C03', label: '表头&页脚' },
            { key: 'C04', label: '展开行数据' },
            { key: 'C05', label: '展开行数据2' },
            { key: 'C06', label: '重新排序' },
            // { key: 'C07', label: '分拣器' },
        ],
    },
    {
        key: 'D',
        label: 'D-自定义单元格',
        children: [
            { key: 'D01', label: '单元格模板' },
            { key: 'D02', label: '单元格注释 ' },
        ]
    },
    { key: 'E01', label: 'E-快速定位', },
    {
        key: 'F',
        label: 'F-编辑',
        children: [
            { key: 'F01', label: '编辑' },
            { key: 'F02', label: '验证' },
            { key: 'F03', label: '视图验证' },
            { key: 'F04', label: '内联编辑' },
            { key: 'F05', label: '窗口编辑' },
        ]
    },
    {
        key: 'G',
        label: 'G-选择器',
        children: [
            { key: 'G01', label: '选择器' },
            { key: 'G02', label: '多范围选择(保存)' },
            { key: 'G03', label: '复选框' },
            { key: 'G04', label: '自动搜索' },
        ]
    },
    {
        key: 'H',
        label: 'H-分组',
        children: [
            { key: 'H01', label: '分组(分组,排序,选中)' },
            { key: 'H02', label: '拖拽分组' },
            { key: 'H03', label: '上下文菜单' },
        ]
    },
    {
        key: 'I',
        label: 'I-聚合',
        children: [
            { key: 'I01', label: '聚合' },
            { key: 'I02', label: '上方聚合' },
            { key: 'I03', label: '下方聚合' },
            { key: 'I04', label: '自定义聚合' },
        ]
    },
    {
        key: 'J',
        label: 'J-合并',
        children: [
            { key: 'J01', label: '合并' },
            { key: 'J02', label: '表头合并' },
        ]
    },
    {
        key: 'K',
        label: 'K-过滤',
        children: [
            { key: 'K01', label: '过滤' },
            { key: 'K02', label: '过滤器' },
            { key: 'K03', label: '过滤搜索' },
        ]
    },
    { key: 'L01', label: 'L-树形数据' },
    {
        key: 'M',
        label: 'M-主细节',
        children: [
            { key: 'M01', label: '明细数据' },
            { key: 'M02', label: '编辑明细' },
        ]
    },
    {
        key: 'N',
        label: 'N-多行显示',
        children: [
            { key: 'N01', label: '行详情' },
            { key: 'N02', label: '折叠标头' },
            { key: 'N03', label: '分组' },
            { key: 'N04', label: '聚合' },
            { key: 'N05', label: '添删' },
            // { key: 'N06', label: '自定义单元格' },
        ]
    },
    // {
    //     key: 'O',
    //     label: '工作表',
    //     children: [
    //         { key: 'O01', label: '未绑定' },
    //         { key: 'O02', label: '绑定数据' },
    //         { key: 'O03', label: '自定义单元格' },
    //         { key: 'O04', label: '自定义标头' },
    //         { key: 'O05', label: '合并单元格' },
    //         { key: 'O06', label: '拖放' },
    //         { key: 'O07', label: '冻结' },
    //         { key: 'O08', label: '公式' },
    //         { key: 'O09', label: '自定义函数' },
    //         { key: 'O10', label: '表格' },
    //         { key: 'O11', label: '导入导出' },
    //     ]
    // },
    // {
    //     key: 'P',
    //     label: '转置网格',
    //     children: [
    //         { key: 'P01', label: '表格' },
    //         { key: 'P02', label: '行组' },
    //     ]
    // },
    // {
    //     key: 'Q',
    //     label: '导入导出',
    //     children: [
    //         { key: 'Q01', label: 'Excel' },
    //         { key: 'Q02', label: '导出进度' },
    //         { key: 'Q03', label: '打印' },
    //     ]
    // },
    // {
    //     key: 'R',
    //     label: '剪切板',
    //     children: [
    //         { key: 'R01', label: '剪切板' },
    //     ]
    // },
    // {
    //     key: 'S',
    //     label: '单元格大小',
    //     children: [
    //         { key: 'S01', label: '拖拽' },
    //         { key: 'S02', label: '自适应' },
    //         { key: 'S03', label: '拖拽延迟适应' },
    //     ]
    // },
    // {
    //     key: 'T',
    //     label: '样式',
    //     children: [
    //         { key: 'T01', label: '行样式' },
    //         { key: 'T02', label: '行高' },
    //         { key: 'T03', label: '列样式' },
    //         { key: 'T04', label: '单元格溢出' },
    //         { key: 'T05', label: 'flexCss对齐' },
    //         { key: 'T06', label: '悬停' },
    //     ]
    // },
    // { key: 'U01', label: '响应式布局' },
    // { key: 'V01', label: '动画样式' },
    // { key: 'W01', label: '持久化' },
    // { key: 'X01', label: '左右布局' },

    {
        key: 'AA',
        label: 'AA-OLAP',
        children: [
            { key: 'AA01', label: '数据枢纽' },
            { key: 'AA02', label: '保留枢纽视图' },
        ]
    },
];

export const selectOptions = [
    { value: '亚洲', label: '亚洲' },
    { value: '欧洲', label: '欧洲' },
    { value: '非洲', label: '非洲' },
    { value: '大洋洲', label: '大洋洲' },
    { value: '南极洲', label: '南极洲' },
    { value: '南美洲', label: '南美洲' },
    { value: '北美洲', label: '北美洲' }
]


export const getData = (cnt) => {
    let countries = "亚洲,欧洲,非洲,大洋洲,南极洲,南美洲,北美洲".split(",")
    const data = [...Array(cnt)].map((_, i) => ({
        id: v4(),
        country: countries[i % countries.length],
        date: new Date(2014, i % 12, i % 28),
        amount: Math.random() * 10000,
        active: (i + 1) % 5 === 0
    }))
    return data
}

export const getData2 = (num) => {
    let countries = "亚洲,欧洲,非洲,大洋洲,南极洲,南美洲,北美洲".split(",")
    const data = [...Array(num)].map((_, i) => ({
        id: i + 1,
        country: countries[i % countries.length],
        downloads: Math.round(Math.random() * 20000),
        sales: Math.random() * 10000,
        expenses: Math.random() * 5000,
        num01: Math.random() * 5000,
        num02: Math.random() * 5000,
        num03: Math.random() * 5000,
        num04: Math.random() * 5000,
        num05: Math.random() * 5000,
        num06: Math.random() * 5000,
        num07: Math.random() * 5000,
        num08: Math.random() * 5000,
        num09: Math.random() * 5000,
        num10: Math.random() * 5000,
        num11: Math.random() * 5000,
        num12: Math.random() * 5000,
        num13: Math.random() * 5000,
        num14: Math.random() * 5000,
        num15: Math.random() * 5000,
        num16: Math.random() * 5000,
        num17: Math.random() * 5000,
        num18: Math.random() * 5000,
        num19: Math.random() * 5000,
        num20: Math.random() * 5000,
        数字: Math.random() * 5000,
        state: i % 4 == 0
    }))
    return data
}

export const getData3 = [
    {
        name: 'Constant Growth',
        currency: 'USD',
        perf: { ytd: .0523, m1: 0.0142, m6: 0.0443, m12: 0.0743 },
        alloc: { stock: 0.17, bond: 0.32, cash: 0.36, other: 0.15, amount: 23432 }
    },
    {
        name: 'Optimus Prime',
        currency: 'EUR',
        perf: { ytd: .0343, m1: 0.043, m6: 0.0244, m12: 0.0543 },
        alloc: { stock: 0.61, bond: 0.8, cash: 0.9, other: 0.22, amount: 43223 }
    },
    {
        name: 'Crypto Planet',
        currency: 'BTC',
        perf: { ytd: .0343, m1: 0.014, m6: 0.034, m12: 0.01243 },
        alloc: { stock: 0.1, bond: 0, cash: 0, other: 0.9, amount: 2234 }
    },
    {
        name: 'MegaZone',
        currency: 'EUR',
        perf: { ytd: .0443, m1: 0.034, m6: 0.0424, m12: 0.0343 },
        alloc: { stock: 0.51, bond: 0.9, cash: 0.8, other: 0.12, amount: 32234 }
    },
    {
        name: 'Serenity',
        currency: 'YEN',
        perf: { ytd: .0522, m1: 0.0143, m6: 0.0458, m12: 0.0732 },
        alloc: { stock: 0.66, bond: 0.09, cash: 0.19, other: 0.06, amount: 65624 }
    }
]
export const getData4 = [
    { symbol: 'RDSA', name: 'Royal Dutch Shell', sector: 'Oil and gas', mcap: 160.12, emp: 90 },
    { symbol: 'ULVR', name: 'Unilever', sector: 'Consumer goods', mcap: 90.42, emp: 171 },
    { symbol: 'HSBA', name: 'HSBC', sector: 'Banking', mcap: 88.11, emp: 267 },
    { symbol: 'BATS', name: 'British American Tobacco', sector: 'Tobacco', mcap: 71.4, emp: 87 },
    { symbol: 'GSK', name: 'GlaxoSmithKline', sector: 'Pharmaceuticals', mcap: 67.38, emp: 97 },
    { symbol: 'SAB', name: 'SABMiller', sector: 'Beverages', mcap: 67.32, emp: 70 },
    { symbol: 'BP', name: 'BP', sector: 'Oil and gas', mcap: 63.13, emp: 97 },
    { symbol: 'VOD', name: 'Vodafone Group', sector: 'Telecomms', mcap: 56.55, emp: 86 },
    { symbol: 'AZN', name: 'AstraZeneca', sector: 'Pharmaceuticals', mcap: 51.23, emp: 57 },
    { symbol: 'RB', name: 'Reckitt Benckiser', sector: 'Consumer goods', mcap: 46.32, emp: 32 },
    { symbol: 'DGE', name: 'Diageo', sector: 'Beverages', mcap: 46.01, emp: 25 },
    { symbol: 'BT.A', name: 'BT Group', sector: 'Telecomms', mcap: 45.61, emp: 89 },
    { symbol: 'LLOY', name: 'Lloyds Banking Group', sector: 'Banking', mcap: 44.11, emp: 120 },
    { symbol: 'BLT', name: 'BHP Billiton', sector: 'Mining', mcap: 41.88, emp: 46 },
    { symbol: 'NG', name: 'National Grid plc', sector: 'Energy', mcap: 36.14, emp: 27 },
    { symbol: 'IMB', name: 'Imperial Brands', sector: 'Tobacco', mcap: 35.78, emp: 38 },
    { symbol: 'RIO', name: 'Rio Tinto Group', sector: 'Mining', mcap: 34.84, emp: 67 },
    { symbol: 'PRU', name: 'Prudential plc', sector: 'Finance', mcap: 31.63, emp: 25 },
    { symbol: 'RBS', name: 'Royal Bank of Scotland Group', sector: 'Banking', mcap: 28.6, emp: 150 },
    { symbol: 'BARC', name: 'Barclays', sector: 'Banking', mcap: 27.18, emp: 150 },
    { symbol: 'ABF', name: 'Associated British Foods', sector: 'Food', mcap: 25.77, emp: 102 },
    { symbol: 'REL', name: 'RELX Group', sector: 'Publishing', mcap: 25.54, emp: 28 },
    { symbol: 'REX', name: 'Rexam', sector: 'Packaging', mcap: 25.54, emp: 19 },
    { symbol: 'CCL', name: 'Carnival Corporation & plc', sector: 'Leisure', mcap: 24.85, emp: 86 },
    { symbol: 'SHP', name: 'Shire plc', sector: 'Pharmaceuticals', mcap: 22.52, emp: 4 },
    { symbol: 'CPG', name: 'Compass Group', sector: 'Food', mcap: 20.21, emp: 471 },
    { symbol: 'WPP', name: 'WPP plc', sector: 'Media', mcap: 19.01, emp: 162 },
    { symbol: 'AV.', name: 'Aviva', sector: 'Insurance', mcap: 17.69, emp: 40 },
    { symbol: 'SKY', name: 'Sky plc', sector: 'Media', mcap: 17.5, emp: 22 },
    { symbol: 'GLEN', name: 'Glencore', sector: 'Mining', mcap: 16.96, emp: 57 },
    { symbol: 'BA.', name: 'BAE Systems', sector: 'Military', mcap: 16.01, emp: 107 },
    { symbol: 'TSCO', name: 'Tesco', sector: 'Supermarket', mcap: 14.92, emp: 519 },
    { symbol: 'SSE', name: 'SSE plc', sector: 'Energy', mcap: 14.03, emp: 19 },
    { symbol: 'STAN', name: 'Standard Chartered', sector: 'Banking', mcap: 13.52, emp: 86 },
    { symbol: 'LGEN', name: 'Legal & General', sector: 'Insurance', mcap: 13.21, emp: 9 },
    { symbol: 'ARM', name: 'ARM Holdings', sector: 'Engineering', mcap: 13.2, emp: 2 },
    { symbol: 'RR.', name: 'Rolls-Royce Holdings', sector: 'Manufacturing', mcap: 11.8, emp: 55 },
    { symbol: 'EXPN', name: 'Experian', sector: 'Information', mcap: 11.1, emp: 17 },
    { symbol: 'IAG', name: 'International Consolidated Airlines Group SA', sector: 'Travel', mcap: 11.01, emp: 58 },
    { symbol: 'CRH', name: 'CRH plc', sector: 'Building materials', mcap: 10.9, emp: 76 },
    { symbol: 'CNA', name: 'Centrica', sector: 'Energy', mcap: 10.72, emp: 40 },
    { symbol: 'SN.', name: 'Smith & Nephew', sector: 'Medical', mcap: 10.27, emp: 11 },
    { symbol: 'ITV', name: 'ITV plc', sector: 'Media', mcap: 10.15, emp: 4 },
    { symbol: 'WOS', name: 'Wolseley plc', sector: 'Building materials', mcap: 9.2, emp: 44 },
    { symbol: 'OML', name: 'Old Mutual', sector: 'Insurance', mcap: 8.45, emp: 54 },
    { symbol: 'LAND', name: 'Land Securities', sector: 'Property', mcap: 8.19, emp: 0 },
    { symbol: 'LSE', name: 'London Stock Exchange Group', sector: 'Finance', mcap: 8.06, emp: 4 },
    { symbol: 'KGF', name: 'Kingfisher plc', sector: 'Retail homeware', mcap: 7.8, emp: 80 },
    { symbol: 'CPI', name: 'Capita', sector: 'Support Services', mcap: 7.38, emp: 46 },
    { symbol: 'BLND', name: 'British Land', sector: 'Property', mcap: 7.13, emp: 0 },
    { symbol: 'WTB', name: 'Whitbread', sector: 'Retail hospitality', mcap: 7.09, emp: 86 },
    { symbol: 'MKS', name: 'Marks & Spencer', sector: 'Retailer', mcap: 7.01, emp: 81 },
    { symbol: 'FRES', name: 'Fresnillo plc', sector: 'Mining', mcap: 6.99, emp: 2 },
    { symbol: 'NXT', name: 'Next plc', sector: 'Retail clothing', mcap: 6.9, emp: 58 },
    { symbol: 'SDR', name: 'Schroders', sector: 'Fund management', mcap: 6.63, emp: 3 },
    { symbol: 'SL', name: 'Standard Life', sector: 'Fund management', mcap: 6.63, emp: 10 },
    { symbol: 'PSON', name: 'Pearson PLC', sector: 'Education', mcap: 6.52, emp: 37 },
    { symbol: 'BNZL', name: 'Bunzl', sector: 'Industrial products', mcap: 6.38, emp: 12 },
    { symbol: 'MNDI', name: 'Mondi', sector: 'Manufacturing', mcap: 6.37, emp: 26 },
    { symbol: 'UU', name: 'United Utilities', sector: 'Water', mcap: 6.36, emp: 5 },
    { symbol: 'PSN', name: 'Persimmon plc', sector: 'Building', mcap: 6.34, emp: 2 },
    { symbol: 'SGE', name: 'Sage Group', sector: 'IT', mcap: 6.26, emp: 12 },
    { symbol: 'EZJ', name: 'EasyJet', sector: 'Travel', mcap: 6.17, emp: 11 },
    { symbol: 'AAL', name: 'Anglo American plc', sector: 'Mining', mcap: 6.09, emp: 100 },
    { symbol: 'TW.', name: 'Taylor Wimpey', sector: 'Building', mcap: 5.99, emp: 3 },
    { symbol: 'TUI', name: 'TUI Group', sector: 'Leisure', mcap: 5.99, emp: 76 },
    { symbol: 'WPG', name: 'Worldpay', sector: 'Payment services', mcap: 5.9, emp: 4 },
    { symbol: 'RRS', name: 'Randgold Resources', sector: 'Mining', mcap: 5.89, emp: 6 },
    { symbol: 'HL', name: 'Hargreaves Lansdown', sector: 'Finance', mcap: 5.87, emp: 0 },
    { symbol: 'BDEV', name: 'Barratt Developments', sector: 'Building', mcap: 5.86, emp: 5 },
    { symbol: 'IHG', name: 'InterContinental Hotels Group', sector: 'Hotels', mcap: 5.75, emp: 345 },
    { symbol: 'BRBY', name: 'Burberry', sector: 'Fashion', mcap: 5.65, emp: 10 },
    { symbol: 'DC.', name: 'Dixons Carphone', sector: 'Retail', mcap: 5.16, emp: 40 },
    { symbol: 'DLG', name: 'Direct Line Group', sector: 'Insurance', mcap: 5.15, emp: 13 },
    { symbol: 'CCH', name: 'Coca-Cola HBC AG', sector: 'Consumer', mcap: 5.1, emp: 38 },
    { symbol: 'SVT', name: 'Severn Trent', sector: 'Water', mcap: 5.04, emp: 8 },
    { symbol: 'DCC', name: 'DCC plc', sector: 'Investments', mcap: 5.03, emp: 9 },
    { symbol: 'SBRY', name: 'Sainsbury\'s', sector: 'Supermarket', mcap: 5.02, emp: 150 },
    { symbol: 'ADM', name: 'Admiral Group', sector: 'Insurance', mcap: 4.91, emp: 2 },
    { symbol: 'GKN', name: 'GKN', sector: 'Manufacturing', mcap: 4.79, emp: 50 },
    { symbol: 'JMAT', name: 'Johnson Matthey', sector: 'Chemicals', mcap: 4.79, emp: 9 },
    { symbol: 'PFG', name: 'Provident Financial', sector: 'Finance', mcap: 4.74, emp: 3 },
    { symbol: 'ANTO', name: 'Antofagasta', sector: 'Mining', mcap: 4.71, emp: 4 },
    { symbol: 'STJ', name: 'St. James\'s Place plc', sector: 'Finance', mcap: 4.68, emp: 1 },
    { symbol: 'ITRK', name: 'Intertek', sector: 'Product testing', mcap: 4.67, emp: 33 },
    { symbol: 'BAB', name: 'Babcock International', sector: 'Engineering', mcap: 4.65, emp: 34 },
    { symbol: 'BKG', name: 'Berkeley Group Holdings', sector: 'Building', mcap: 4.6, emp: 2 },
    { symbol: 'ISAT', name: 'Inmarsat', sector: 'Telecomms', mcap: 4.47, emp: 1 },
    { symbol: 'TPK', name: 'Travis Perkins', sector: 'Retailer', mcap: 4.46, emp: 24 },
    { symbol: 'HMSO', name: 'Hammerson', sector: 'Property', mcap: 4.42, emp: 0 },
    { symbol: 'MERL', name: 'Merlin Entertainments', sector: 'Leisure', mcap: 4.42, emp: 28 },
    { symbol: 'RMG', name: 'Royal Mail', sector: 'Delivery', mcap: 4.41, emp: 150 },
    { symbol: 'AHT', name: 'Ashtead Group', sector: 'Equipment rental', mcap: 4.26, emp: 12 },
    { symbol: 'RSA', name: 'RSA Insurance Group', sector: 'Insurance', mcap: 4.16, emp: 21 },
    { symbol: 'III', name: '3i', sector: 'Private equity', mcap: 4.06, emp: 0 },
    { symbol: 'INTU', name: 'Intu Properties', sector: 'Property', mcap: 3.89, emp: 2 },
    { symbol: 'SMIN', name: 'Smiths Group', sector: 'Engineering', mcap: 3.84, emp: 23 },
    { symbol: 'HIK', name: 'Hikma Pharmaceuticals', sector: 'Manufacturing', mcap: 3.71, emp: 6 },
    { symbol: 'ADN', name: 'Aberdeen Asset Management', sector: 'Fund management', mcap: 3.14, emp: 1 },
    { symbol: 'SPD', name: 'Sports Direct', sector: 'Retail', mcap: 2.4, emp: 17 }
]

export const getData5 = (num) => {
    const pickOne = (items) => items[randBetween(0, items.length - 1)];
    const randBetween = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
    const countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), products = 'Widgets,Gadgets,Yahoos'.split(',')
    const data = [...Array(num)].map((_, i) => ({
        id: i + 1,
        country: pickOne(countries),
        product: pickOne(products),
        discount: Math.random() * .3,
        downloads: Math.round(Math.random() * 200000),
        sales: Math.random() * 100000,
        expenses: Math.random() * 50000,
        num01: Math.random() * 5000,
        num02: Math.random() * 5000,
        num03: Math.random() * 5000,
        num04: Math.random() * 5000,
        num05: Math.random() * 5000,
        num06: Math.random() * 5000,
        num07: Math.random() * 5000,
        num08: Math.random() * 5000,
        num09: Math.random() * 5000,
        state: i % 4 == 0
    }))
    return data
}

export const getData6 = [{
    name: 'Jack Smith',
    checks: [{
        name: 'check1',
        earnings: [
            { name: 'hourly', hours: 30.0, rate: 15.0 },
            { name: 'overtime', hours: 10.0, rate: 20.0 },
            { name: 'bonus', hours: 5.0, rate: 30.0 }
        ]
    }, {
        name: 'check2',
        earnings: [
            { name: 'hourly', hours: 20.0, rate: 18.0 },
            { name: 'overtime', hours: 20.0, rate: 24.0 }
        ]
    }]
},
{
    name: 'Bill Smith',
    checks: [{
        name: 'check1',
        earnings: [
            { name: 'hourly', hours: 30.0, rate: 15.0 },
            { name: 'overtime', hours: 10.0, rate: 20.0 },
            { name: 'bonus', hours: 5.0, rate: 30.0 }
        ]
    }, {
        name: 'check2',
        earnings: [
            { name: 'hourly', hours: 20.0, rate: 18.0 },
            { name: 'overtime', hours: 20.0, rate: 24.0 }
        ]
    }]
},
{
    name: 'Jane Smith',
    checks: [{
        name: 'check1',
        earnings: [
            { name: 'hourly', hours: 30.0, rate: 15.0 },
            { name: 'overtime', hours: 10.0, rate: 20.0 },
            { name: 'bonus', hours: 5.0, rate: 30.0 }
        ]
    }, {
        name: 'check2',
        earnings: [
            { name: 'hourly', hours: 20.0, rate: 18.0 },
            { name: 'overtime', hours: 20.0, rate: 24.0 }
        ]
    }]
}]



const randBetween = (min, max) => {
    return Math.floor(Math.random() * (max - min + 1) + min);
}
const randArray = (arr) => {
    return arr[randBetween(0, arr.length - 1)];
}
const clone = (obj) => {
    if (isFunction(Object.assign)) { return Object.assign({}, obj); }
    let clone = {}
    for (let prop in obj) { if (obj.hasOwnProperty(prop)) { clone[prop] = obj[prop] } }
    return clone
}

export const MultiRowConfig = (num) => {
    const firstNames = 'Aaron,Paul,John,Mark,Sue,Tom,Bill,Joe,Tony,Brad,Frank,Chris,Pat'.split(','),
        lastNames = 'Smith,Johnson,Richards,Bannon,Wong,Peters,White,Brown,Adams,Jennings'.split(','),
        cities = 'York,Paris,Rome,Cairo,Florence,Sidney,Hamburg,Vancouver'.split(','),
        states = 'SP,RS,RN,SC,CS,RT,BC'.split(','),
        today = new Date()
    const cityMap = new DataMap(cities)
    let shippers = [
        { id: 0, name: 'Speedy Express', email: 'speedy@gmail.com', phone: '431-3234', express: true },
        { id: 1, name: 'Flash Delivery', email: 'flash@gmail.com', phone: '431-6563', express: true },
        { id: 2, name: 'Logitrax', email: 'logitrax@gmail.com', phone: '431-3981', express: false },
        { id: 3, name: 'Acme Inc', email: 'acme@gmail.com', phone: '431-3113', express: false }
    ]

    const customers = [...Array(50)].map((_, i) => {
        const first = randArray(firstNames), last = randArray(lastNames)
        return {
            id: i + 1,
            name: first + ' ' + last,
            address: randBetween(100, 10000) + ' ' + randArray(lastNames) + ' St.',
            city: randArray(cities),
            state: randArray(states),
            zip: format('{p1:d5}-{p2:d3}', { p1: randBetween(10000, 99999), p2: randBetween(100, 999) }),
            email: first + '.' + last + '@gmail.com',
            phone: format('{p1:d3}-{p2:d4}', { p1: randBetween(100, 999), p2: randBetween(1000, 9999) })
        }
    })


    const order = [...Array(num)].map((_, i) => {
        const shipped = DateTime.addDays(today, -randBetween(1, 3000));
        return {
            id: i + 1,
            date: DateTime.addDays(shipped, -randBetween(1, 5)),
            shippedDate: shipped,
            amount: randBetween(10000, 500000) / 100,
            customer: clone(randArray(customers)),
            shipper: clone(randArray(shippers))
        }
    })
    const TableType = {
        Compact: [
            {
                header: 'Order',
                colspan: 2,
                cells: [
                    { binding: 'id', header: 'ID', cssClass: 'id', isReadOnly: true },
                    { binding: 'date', header: 'date' },
                    { binding: 'amount', header: 'amount', format: 'c', cssClass: 'amount' },
                    { binding: 'shippedDate', header: 'shippedDate' }
                ]
            },
            {
                header: 'Customer',
                colspan: 3,
                cells: [
                    { binding: 'customer.name', header: 'name' },
                    { binding: 'customer.email', header: 'email', colspan: 2, cssClass: 'email' },
                    { binding: 'customer.address', header: 'address' },
                    { binding: 'customer.city', header: 'city', dataMap: cityMap },
                    { binding: 'customer.state', header: 'state', width: 100 }
                ]
            },
            {
                header: 'Shipper',
                cells: [
                    { binding: 'shipper.name', header: 'name', colspan: 2 },
                    { binding: 'shipper.email', header: 'email', cssClass: 'email' },
                    { binding: 'shipper.express', header: 'express' }
                ]
            }
        ],
        Detailed: [
            {
                header: 'Order',
                colspan: 2,
                cells: [
                    { binding: 'id', header: 'ID', colspan: 2, cssClass: 'id' },
                    { binding: 'amount', header: 'amount', format: 'c', colspan: 2, cssClass: 'amount' },
                    { binding: 'date', header: 'date' },
                    { binding: 'shippedDate', header: 'shippedDate' }
                ]
            },
            {
                header: 'Customer',
                colspan: 3,
                cells: [
                    { binding: 'customer.name', header: 'name' },
                    { binding: 'customer.email', header: 'email', colspan: 2, cssClass: 'email' },
                    { binding: 'customer.address', header: 'address', colspan: 2 },
                    { binding: 'customer.phone', header: 'phone' },
                    { binding: 'customer.city', header: 'city', dataMap: cityMap },
                    { binding: 'customer.state', header: 'state', width: 100 },
                    { binding: 'customer.zip', header: 'zip' },
                ]
            },
            {
                header: 'Shipper',
                cells: [
                    { binding: 'shipper.name', header: 'name' },
                    { binding: 'shipper.email', header: 'email', cssClass: 'email' },
                    { binding: 'shipper.express', header: 'express' }
                ]
            }
        ],
        Traditional: [
            { cells: [{ binding: 'id', header: 'ID', cssClass: 'id', isReadOnly: true }] },
            { cells: [{ binding: 'date', header: 'Ordered' }] },
            { cells: [{ binding: 'shippedDate', header: 'Shipped' }] },
            { cells: [{ binding: 'amount', header: 'Amount', format: 'c', cssClass: 'amount' }] },
            { cells: [{ binding: 'customer.name', header: 'Customer' }] },
            { cells: [{ binding: 'customer.address', header: 'Address', wordWrap: true }] },
            { cells: [{ binding: 'customer.city', header: 'City', dataMap: cityMap }] },
            { cells: [{ binding: 'customer.state', header: 'State', width: 100 }] },
            { cells: [{ binding: 'customer.zip', header: 'Zip' }] },
            { cells: [{ binding: 'customer.email', header: 'Customer Email', cssClass: 'email' }] },
            { cells: [{ binding: 'customer.phone', header: 'Customer Phone' }] },
            { cells: [{ binding: 'shipper.name', header: 'Shipper' }] },
            { cells: [{ binding: 'shipper.email', header: 'Shipper Email', cssClass: 'email' }] },
            { cells: [{ binding: 'shipper.phone', header: 'Shipper Phone' }] },
            { cells: [{ binding: 'shipper.express', header: 'Express' }] }
        ]
    }
    return { TableType, data: order }
}

export const MultiRowConfig02 = (num) => {
    const countries = 'US,Germany,UK,Japan,Italy,Greece,Portugal,Spain'.split(','),
        names = 'Abe,Bob,Chuck,Dan,Ed,Fred'.split(','),
        colors = 'Red,Green,Blue,White,Black,Yellow,Orange'.split(','),
        today = new Date()


    const data = [...Array(num)].map((_, i) => ({
        id: i + 1,
        date: DateTime.addDays(today, -i),
        name: names[i % names.length],
        country: countries[i % countries.length],
        color: colors[i % colors.length],
        active: i % 5 != 0,
        downloads: Math.round(Math.random() * 200000),
        sales: Math.round(Math.random() * 20000),
        expenses: Math.round(Math.random() * 10000)
    }))

    const TableType = [
        { cells: [{ binding: 'id', header: 'ID' }] },
        { cells: [{ binding: 'country', header: 'Country' }] },
        { cells: [{ binding: 'color', header: 'Color' }] },
        {
            cells: [
                { binding: 'sales', header: 'Sales', cssClass: 'sales', aggregate: 'Sum' },
                { binding: 'expenses', header: 'Expenses', cssClass: 'expenses', aggregate: 'Sum' }
            ]
        }
    ]

    return { data, TableType }
}


export const OlapData01 = (num) => {
    const products = [
        { product: 'Wijmo', platform: 'Web' },
        { product: 'ActiveReports', platform: 'Desktop' },
        { product: 'ActiveReportsJS', platform: 'Web' },
        { product: 'ComponentOne', platform: 'Desktop' },
        { product: 'Spread', platform: 'Desktop' },
        { product: 'SpreadJS', platform: 'Web' },
        { product: 'GCDocs', platform: 'Desktop' }
    ]
    const agents = [
        { agent: 'Ashlyn Dunlop', region: 'East' },
        { agent: 'Keith Vang', region: 'East' },
        { agent: 'Bobbi Rodrigues', region: 'West' },
        { agent: 'Charli Medina', region: 'West' },
        { agent: 'Kaitlin Salt', region: 'West' },
    ]
    const year = new Date().getFullYear()
    const data = [...Array(num)].map((_, i) => {
        const productIndex = randBetween(0, 6);
        const agentIndex = randBetween(0, 4);
        return {
            id: i + 1,
            platform: products[productIndex].platform,
            product: products[productIndex].product,
            agent: agents[agentIndex].agent,
            region: agents[agentIndex].region,
            date: new Date(year - randBetween(0, 2), randBetween(0, 11), randBetween(0, 27)),
            sales: randBetween(1500, 3500),
            downloads: randBetween(10, 200),
            revenue: randBetween(500, 1000)
        }
    })
    return data
}